//    Copyright (C) Kherty.  All rights reserved.
using System;
using System.Windows.Media.Effects;
using OpenLS.Core.Serialization;

namespace OpenLS.Drawing
{
    public class PresetShadowEffect : ImageEffect
    {
        private ColorBase color;
        private double dir;
        private double dist;

        private PresetShadowValue val;

        public ColorBase Color
        {
            get { return color; }
            set { color = value; }
        }

        public PresetShadowValue Value
        {
            get { return val; }
            set { val = value; }
        }

        public double Distance
        {
            get { return dist; }
            set { dist = value; }
        }

        public double Direction
        {
            get { return dir; }
            set { dir = value; }
        }


        internal override void ReadXmlCore(ReadContext context)
        {
            using (var c = context.Read("prstShdw"))
            {
                Value = c.GetEnum<PresetShadowValue>("prst");
                Distance = SerializationHelper.GetOptionalPositiveCoordinate(c, "dist", 0);
                Direction = SerializationHelper.GetOptionalPositiveFixedAngle(c, "dir", 0);
                Color = ColorBase.ReadColor(c);
            }
        }

        internal override void WriteXmlCore(WriteContext context)
        {
            using (WriteContext c = context.Write("prstShdw"))
            {
                c.SetEnum("prst", Value);
                SerializationHelper.SetOptionalPositiveCoordinate(c, "dist", Distance, 0);
                SerializationHelper.SetOptionalPositiveFixedAngle(c, "dir", Direction, 0);
                c.WriteElement(Color); //\\OK?
            }
        }

        public override BitmapEffect BitmapEffect(ColorScheme colorScheme)
        {
            {
                throw new NotImplementedException();
            }
        }
    }
}